Berkeley-Data / irrigation_detection

MIT License
2 stars 1 forks source link

EDA - Google Earth Tool #69

Open taeil opened 3 years ago

taeil commented 3 years ago

input:

output

suryagutta commented 3 years ago

In the main BigEarthNet archive, we have a JSON file for each image patch with the coordinates in UTM format apart from additional information. The plan is that we can use that information and grab the temporal patch using google earth engine API. For that, we need to convert UTM format to latitude and longitude.

Had a meeting with Ernesto to validate his formula to convert UTM to latitude and longitude. It worked fine for one BigEarthNet sample (which has sea/ocean label). It failed for the following sample (when there is a negative value (-9) for central_meridian): {"labels": ["Continuous urban fabric", "Discontinuous urban fabric", "Permanently irrigated land", "Rice fields"], "coordinates": {"ulx": 540780, "uly": 4312440, "lrx": 541980, "lry": 4311240}, "projection": "PROJCS[\"WGS 84 / UTM zone 29N\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[**"central_meridian\",-9**],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"32629\"]]", "tile_source": "S2A_MSIL1C_20171221T112501_N0206_R037_T29SND_20171221T114356.SAFE", "acquisition_date": "2017-12-21 11:25:01"}

Helpful link to find a location using UTM: rcn.montana.edu/Resources/Converter.aspx

@oropezaev is troubleshooting the issue. He is going to check with his colleagues on the conversion issue. It's more about domain knowledge expertise!

suryagutta commented 3 years ago

Why we need latitude and longitude? We need to provide a bounding box / Rectangle to the google earth engine API to grab the image Code: ee.Geometry.Rectangle([self.center_lon - self.edge_len / 2, self.center_lat - self.edge_len / 2, self.center_lon + self.edge_len / 2, self.center_lat + self.edge_len / 2])

suryagutta commented 3 years ago

Google API : ee.Geometry.Rectangle(coords, proj, geodesic, evenOdd) coords (type:List): The minimum and maximum corners of the rectangle, as a list of two points each in the format of GeoJSON 'Point' coordinates, or a list of two ee.Geometry describing a point, or a list of four numbers in the order xMin, yMin, xMax, yMax. Source: https://developers.google.com/earth-engine/apidocs/ee-geometry-rectangle#python

taeil commented 3 years ago

It doesn't need to be geo coordinates.

suryagutta commented 3 years ago

Hi @oropezaev , from the metadata("coordinates": {"ulx": 540780, "uly": 4312440, "lrx": 541980, "lry": 4311240}), I took ulx and uly coordinates, Zone and Datum, and used https://awsm-tools.com/geo/utm-to-geographic to convert to latitude and longitude. The converted latitude and longitude show a location in Portugal (seems to be a recently developed housing area. Some of it could be agricultural land a few years before.). Portugal is one of the 10 countries BigEarthNet data is based on. Sharing this info. as this tool is another option for validating your logic.

image

oropezaev commented 3 years ago

EDA on Google Earth matching BigEarthNet is complete with possible updates after discussion. The original notebook was modified to adapt it to BigEarthNet patches. Now we are able to create patches for different dates. It can be easily scaled to reproduce the whole dataset. However, the tif files are downloaded to Google Drive only.

suryagutta commented 3 years ago

@oropezaev Can this be a python script instead of a jupyter notebook? I didn't look into your notebook yet.