-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
ValueError: Must pass either crs or epsg #12
Comments
I used raster to polygon geoprocessing tool in order to see how good the result is overlayed. This is the geospatial reference information screen that shows the mask that is created with the sam-generate wgs84 coordinate system.
By the way, I would like to say huge thanks for creating this amazing module open source, thank you so much for your amazing work. @giswqs You are the real MVP in GIS. I would like to say sorry if my workflow is not correct and flagged this as a bug. Regards. |
What |
Can you provide complete source code that can reproduce the issue? |
I didn't pass any bbox value since I thought the clipped region that I derivated from the inclusive aerial image has already bbox regions inside of its metadata. I didn't use this:
and this function: |
Can you share the input geotiff for debugging? |
It appears that the inference runs successfully. You can use the following function directly to debug the issue. https://samgeo.gishub.org/samgeo/#samgeo.samgeo.SamGeo.tiff_to_vector def tiff_to_vector(tiff_path, output, simplify_tolerance=None, **kwargs):
"""Convert a tiff file to a gpkg file.
Args:
tiff_path (str): The path to the tiff file.
output (str): The path to the vector file.
simplify_tolerance (_type_, optional): The simplify tolerance. Defaults to None.
"""
import geopandas as gpd
import rasterio
from rasterio import features
with rasterio.open(tiff_path) as src:
band = src.read()
mask = band != 0
shapes = features.shapes(band, mask=mask, transform=src.transform)
fc = [
{"geometry": shapely.geometry.shape(shape), "properties": {"value": value}}
for shape, value in shapes
]
if simplify_tolerance is not None:
for i in fc:
i["geometry"] = i["geometry"].simplify(tolerance=simplify_tolerance)
gdf = gpd.GeoDataFrame.from_features(fc)
gdf.set_crs(epsg=src.crs.to_epsg(), inplace=True)
gdf.to_file(output, **kwargs) |
Do you mind if I ask how to share the sample data with you? Which vendor do you prefer, I can send it with an uploaded file link(can share it here or right into your mailbox). The system doesn't allow data of more than 25 MB, and my sample data is around ~100MB. I refrain from choosing a method that is not suitable for you. I want to contribute even if this sample data will improve your workflow. |
You can upload it to me via this link. |
I think the problem is your input dataset. From the image extent numbers, it is clearly those numbers are not lat/lon. They are likely epsg:3857. But the CRS shows that it is WGS 1984, which is wrong. So my question is how did you get that dataset? The CRS was not assigned properly. |
Thank you so much, dear Wu. The problem is solved by changing the data's geospatial coordinate reference system into GCS_WGS_1984(4326) from pseudo-Mercator(3857), so extend parameters are converted into decimal degrees and the inference code worked flawlessly. It is right that there is a problem with the main sample tiff, I derived it from our database(which is shown and used in [here](https://sehirharitasi.ibb.gov.tr/ as "2022 Uydu" in the layer selection section). The sample tiff was ESRGAN applied version of raw data(It was the project in which I enhanced raw data with super-resolution techniques). There could be an issue when mosaicking tile files into a raster file. However, bear in mind: The function in the sample notebook still asks for crs for being set by the user while the inference function runs great if you set the crs in it.
|
This bug has been fixed in v0.3.0. Please update the package and try again. |
Hello everyone, both the mask that is created and tiff have been projected with 4326, WGS 84 coordinate system. It can be easily seen on the map with their current projection without on the fly action. The mask that was created after sam generate function has 4326 coordinate system. However, when I try to use tiff_to_vector or tiff_to_package functions, I got no crs or epsg is set error. How to pass crs or epsg into these functions?
I implemented the notebook tutorial code with my projected tiff exactly as it is described.
Thanks in advance.
The text was updated successfully, but these errors were encountered: