Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lon and lat ranges (max of 180 vs 360 deg) in geospatial data #435

Closed
atrisovic opened this issue Apr 12, 2023 · 4 comments
Closed

Lon and lat ranges (max of 180 vs 360 deg) in geospatial data #435

atrisovic opened this issue Apr 12, 2023 · 4 comments

Comments

@atrisovic
Copy link

TLDR

In some geospatial data longitude is given in the range of 0-360 degrees, while in the others the range is -180-180 degrees. Does the CF-Convention contain information which range is used in the data, and how is it denoted?

Does this ambiguity sometimes exist for latitude also, or it is always in the range -90-90 degrees?

Question

Hi everyone,

We are trying to automatically extract metadata from geospatial files (netCDF and HDF5) and populate that information in the geospatial metadata fields in the Dataverse (dataverse.org) data repository. In particular, we have a geographicBoundingBox metadata field that we want to populate using the info from the standard fields geospatial_lat_min, geospatial_lat_max, geospatial_lon_min, geospatial_lon_max that are typically found within these data.

The issue is that lon is sometimes given in the range of 0-360, and sometimes in the range of -180-180 degrees.
Does the CF-convention denote which range is used for lon and lat in the data?

From what I've seen, if the units attribute is set to degrees_east, then the range is typically 0-360 for longitude, while if the units is degrees_west the range is -180-180 (see examples below). Is this the general rule, or there is a better way to see the range?

Also, does this ambiguity sometimes exist for latitude, or it is always in the range -90-90 degrees?

Example

One of our test datasets contains the following metadata:

 <attribute name="standard_name_vocabulary" value="CF Standard Name Table v31" />
  <attribute name="geospatial_bounds_crs" value="EPSG:4326" />
  <attribute name="geospatial_lat_min" type="double" value="41.8" />
  <attribute name="geospatial_lat_max" type="double" value="49.62" />
  <attribute name="geospatial_lon_min" type="double" value="343.68" />
  <attribute name="geospatial_lon_max" type="double" value="353.78" />
  <attribute name="geospatial_lat_units" value="degrees_north" />
  <attribute name="geospatial_lon_units" value="degrees_east" />

Another example contains this metadata:

  <attribute name="Conventions" value="CF-1.6" />
  <attribute name="geospatial_lat_min" value="25.066666666666666" />
  <attribute name="geospatial_lat_max" value="49.40000000000000" />
  <attribute name="geospatial_lon_min" value="-124.7666666333333" />
  <attribute name="geospatial_lon_max" value="-67.058333300000015" />
  <attribute name="geospatial_lon_resolution" value="0.041666666666666" />
  <attribute name="geospatial_lat_resolution" value="0.041666666666666" />
  <attribute name="geospatial_lat_units" value="decimal_degrees north" />
  <attribute name="geospatial_lon_units" value="decimal_degrees east" />
  <attribute name="coordinate_system" value="EPSG:4326" />
  <attribute name="geospatial_bounds" value="POLYGON((-124.7666666333333 49.400000000000000, -124.7666666333333 25.066666666666666, -67.058333300000015 25.066666666666666, -67.058333300000015 49.400000000000000, -124.7666666333333 49.400000000000000))" />
@taylor13
Copy link

Coordinate values in CF files must be stored monotonically increasing or decreasing, so you could extract the first and last coordinate values stored to determine the domain.

@atrisovic
Copy link
Author

Hi @taylor13, thanks for the prompt reply!

I'm not sure I completely understand. For instance, in my examples:

<attribute name="geospatial_lon_min" value="343.68" /> and <attribute name="geospatial_lon_max" value="353.78" />

and

<attribute name="geospatial_lon_min" value="-124.7666666333333" /> and <attribute name="geospatial_lon_max" value="-67.058333300000015" />

both min longitudes are smaller than max longitudes. Can I infer from that the range is 0-360?

The issue is that sometimes only a small region or a city will be captured in the data and for example the region at the longitude of (50, 60) could work for both ranges (0-360 and -180-180).

@sethmcg
Copy link
Contributor

sethmcg commented Apr 12, 2023

In my experience, when it comes to this issue, it's better to check the data explicitly than infer the answer from metadata. Even when the choice of longitude range was specified by convention, I have run into a lot of data that did not conform to the spec. Plus, it's very easy for attributes recording min & max values to become out of sync with the actual contents of the file. Unless I am certain that nobody has touched the file since it was originally written, I regard them as unreliable.

As Karl said, coordinate variables have to be monotonic, so you only need to check the first and last coordinates rather than the whole thing. If one of them is > 180, the domain is 0:360. If one of them is <0, the domain is -180:180. If both are between 0 and 180, the answer is indeterminate.

The CF Conventions doesn't have anything to say about degrees_west. It's a legal unit because it's understood by udunits2, but the Conventions always recommend degrees_east for longitudes.

Latitude should always be in the [-90:90] range.

@JonathanGregory
Copy link
Contributor

Closing this issue because the question has been answered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants