Closed ninsbl closed 2 weeks ago
What about using GRASS raster or vector maps as aoi too?
@ninsbl
# Here we need to reproject if location CRS != EPSG:4326 # Note that shapely geometries are unaware of the CRS
I think the way to do that would be to:
I don't think that is really clean, but I couldn't find a way to reproject the Vector in Python on the go... Can you refere me to any references, if any, that could help reach a cleaner approach, or if this is good enough I will implement it...
I would use something along these lines: https://pcjericks.github.io/py-gdalogr-cookbook/projection.html
It adds GDAL (osr/ogr) as an external dependency, but that should be OK.
You can get the source crs with g.proj
.
Thanks. I have been trying to use it, but there is some trouble because Shapely uses (longitude, latitude), while GDAL uses (latitude, longitude)... We could easily convert one to the other, but the problem is that when I try to reproject a vector from EPSG:4326 to EPSG:3358, I do have to convert the shapely object from (longitude, latitude) to (latitude, longitude), but when I try to reproject the other way around (from EPSG:3358 to EPSG:4326), I don't need to.... So apart from this case, I think that there might be other edge cases, that might cause other problems... (Also there is some slight errors with the coordinates, but I think it just a precision problem).
Also, I am still not sure why I don't need to convert the coordinates order, when converting from EPSG:3358 to EPSG:4326.
What about we use a similar implementation like in i.sentinel.download. https://github.com/OSGeo/grass-addons/blob/grass8/src/imagery/i.sentinel/i.sentinel.download/i.sentinel.download.py#L246
Or if this doesn't have a major drawbacks?
- Create a temp_location with EPSG:4326 CRS.
- Reproject the targeted vector into the temp_location.
- Open the new reprojected vector, and get the wkb value from it.
- Delete the temp_location.
- Create the shapely file with the WKB and return it.
IMO, something on the lines i.sentinel.download does could work, in that way we do not need any extra dependency nor creating a temp-location. What do you think, @ninsbl and @lucadelu?
Implemented it in a very similar way to i.sentinel.download method. https://github.com/OSGeo/grass-addons/pull/1097
@ninsbl Regarding the GeoJSON file support, during the last meeting we discussed that if a user have a GeoJSON file, it can first be imported as a vector map, and that vector map could then be used to get the AOI, and so that would be a way to use GeoJSON indirectly. Do you think that it is enough to have it that way, or would it be better if direct GeoJSON support was added as well?
Closing this issue.
Note that the code is not tested...