waldoj / frostline

A dataset, API, and parser for USDA plant hardiness zones.
https://phzmapi.org/
MIT License
149 stars 25 forks source link

Deal with askew coordinates #31

Closed waldoj closed 7 years ago

waldoj commented 7 years ago

We're getting coordinates over the border in Canada, and our coordinates within the U.S. appear to be wrong. e.g., 35.55, -76.65 is in ZIP 27810, but this has those coordinates in zone 8b, but that ZIP is in zone 8a. So something isn't right here.

waldoj commented 7 years ago

Yuuuuup, this is a projection problem. The phm_us.prj file specifies that this uses:

GEOGCS["GCS_North_American_1983",
    DATUM["North_American_Datum_1983",
        SPHEROID["GRS_1980",6378137.0,298.257222101]],
    PRIMEM["Greenwich",0.0],
    UNIT["Degree",0.0174532925199433]]

This may complicate things beyond what is plausible for me to deal with via a simple iteration over a grid. :-/ But I'll try!

waldoj commented 7 years ago

OK, so the basic problem here is that PHZ grid data is stored as NAD 1983, and it should perhaps instead be stored as WGS 84 (EPSG:4326). (This is surely a projection problem, whatever the proper projection is.) gdal is the tool for this. My efforts so far have failed, e.g.:

# gdaltransform -s_srs EPSG:4326 -t_srs EPSG:32617 phm_us.asc phm_us_2.asc

ERROR 4: `phm_us_2.asc' does not exist in the file system,
and is not recognised as a supported dataset name.

(Removed: a big list of drivers.) Maybe ogr2ogr can read ESRI ASCII Raster, but not write it?

Anyway, there are two necessary tasks here:

  1. Identify the proper projection to use for this task.
  2. Get gdal to perform that conversion.
waldoj commented 7 years ago

Solution: Redo the whole damn thing as Shapefile -> GeoJSON -> JSON pipeline, and see how that goes.

waldoj commented 7 years ago

I am not a proud man.

waldoj commented 7 years ago

Obviated by #32.