Giter VIP home page Giter VIP logo

Comments (12)

giswqs avatar giswqs commented on May 16, 2024 1

You can upload it to me via this link.

from segment-geospatial.

giswqs avatar giswqs commented on May 16, 2024 1

This bug has been fixed in v0.3.0. Please update the package and try again.

from segment-geospatial.

sukruburakcetin avatar sukruburakcetin commented on May 16, 2024

sam_geo1

I used raster to polygon geoprocessing tool in order to see how good the result is overlayed.

sam_geo2

This is the geospatial reference information screen that shows the mask that is created with the sam-generate wgs84 coordinate system.

sam_geo3
And this is the original tiff file that is used for mask generation. It also has wgs84 coordinate system as described in its geospatial reference information.

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.

from segment-geospatial.

giswqs avatar giswqs commented on May 16, 2024

What bbox did you use?

from segment-geospatial.

giswqs avatar giswqs commented on May 16, 2024

Can you provide complete source code that can reproduce the issue?

from segment-geospatial.

sukruburakcetin avatar sukruburakcetin commented on May 16, 2024

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:

if m.user_roi_bounds() is not None:
    bbox = m.user_roi_bounds()
else:
    bbox = [-95.3704, 29.6762, -95.368, 29.6775]

and this function:
tms_to_geotiff(output=image, bbox=bbox, zoom=20, source='Satellite')

This is my notebook:
sam_geo4

from segment-geospatial.

giswqs avatar giswqs commented on May 16, 2024

Can you share the input geotiff for debugging?

from segment-geospatial.

giswqs avatar giswqs commented on May 16, 2024

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)

from segment-geospatial.

sukruburakcetin avatar sukruburakcetin commented on May 16, 2024

Can you share the input geotiff for debugging?

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.

from segment-geospatial.

sukruburakcetin avatar sukruburakcetin commented on May 16, 2024

Okay, with the inference function you have provided, I was able to create a shape vector file with WKID code 3857 without any complications(it is a different projection so you cannot overlay it properly). However, when I try it with the code 4326, the shapefile was created with polygon attributes but you cannot show data on the map viewer.

I have tried a bunch of other epsg codes, so you can easily see output on the viewer but it cannot be overlayed on the real tiff data due to their projections do not match. They all work but in a way of is not expected.

This is how I debugged it:
sam_geo6
And this is the output:
sam_geo5

All of them work but their end results don't match(it is expected). The only one which is not worked: is the attempt with code 4326. The shapefile was created but cannot be seen.

Do you mind if I request to try it out with the sample I provided via your link? Thank you so much for your patience and efforts, dear Wu.

from segment-geospatial.

giswqs avatar giswqs commented on May 16, 2024

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.

image

image

The correct one should look like this.
image

from segment-geospatial.

sukruburakcetin avatar sukruburakcetin commented on May 16, 2024

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.
sam_geo7

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.
sam_geo8

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.

shapefile = 'segment_gpu_new_decimal_degrees.shp'
sam.tiff_to_vector(mask, shapefile)

from segment-geospatial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.