IndigoWizard / NDVI-Viewer

Monitor Vegetation Health by Viewing & Comparing NDVI Values & Satellite Images On The Fly!
https://ndvi-viewer.streamlit.app/
16 stars 6 forks source link

Input: uplaoded geojson with multiple geometries #22

Closed IndigoWizard closed 11 months ago

IndigoWizard commented 1 year ago

The _upload_filesproc function is not reading all the geometries within a single GeoJSON file, instead it only parse the first geometry and ignores the rest.

PavlosDem99 commented 1 year ago

Hello @IndigoWizard, sorry for the delay I was ready to open an issue for the problem I faced with the geojson file. As I see, you did it by yourself. I will wait until the issue closes to check it again.

IndigoWizard commented 1 year ago

@PavlosDem99 I took your feedback actually and I'm working on it right now, but I might end up releasing the v1.0.0 later today then pushing the fixes as 1.0.1. I'll try to release the test from a different branch at the same time to get feedback though.

Can you provide more details on your end though (structure sample, type, how you created it... etc)? becaues geojson files from the geojson.io are working fine.

PavlosDem99 commented 1 year ago

I tried two geojson files. The first one, I created using the way you suggest in your app (through geojson.io) and second one I created it using QGIS. 1st case: When I upload the geojson file (Mapbox.geojson), this shows up. image

2nd case : When I upload the geojson file (QGIS.geojson), this shows up.

image

IndigoWizard commented 1 year ago

@PavlosDem99 That's odd, because if you are generating the Mapbox.geojson with https://geojson.io/ it should have the same structure and it should work as the example bellow.

The problem may also reside in the structure of the GeoJSON if it's created in a different way, I designed the app with the common structure of geojson in mind and based it of the most available source to get one on the fly (hence the https://geojson.io/). See the second file (QGIS.geojson), it says invalid geometry, unless you are entering something else than a polygon (rectangle, polygon, circle) or a LineString then it won't work.

I assume you have Points in your file, points geometry don't work (it's a location, not a aoi). If you have multiple geometries within a GeoJSON file and points are at the top then it won't work either. Try having the polygon first in the structure then points afterwards and it should work.

Here's a sample of a rectangle that I tested and it worked from https://geojson.io/:

GeoJSON sample (rectangle)

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "coordinates": [
          [
            [
              2.2663633276871167,
              36.81132100389685
            ],
            [
              2.2663633276871167,
              36.343869534766384
            ],
            [
              3.1810888910050608,
              36.343869534766384
            ],
            [
              3.1810888910050608,
              36.81132100389685
            ],
            [
              2.2663633276871167,
              36.81132100389685
            ]
          ]
        ],
        "type": "Polygon"
      }
    }
  ]
}
#### Rectangle #### LineString
image image
PavlosDem99 commented 1 year ago

Unfortunately, the geojson file that I generated using QGIS is a polygon. I tried the geojson file you provided above, and it works perfectly. image

💡 A tip: It will be better when the geojson file is being uploaded to zoom in the region of the geojson file.

IndigoWizard commented 1 year ago

@PavlosDem99 I see, I'll try to set it up in a way to also match different structures such of a QGIS based geojson. I'm also working on fixing the issue to make the map focus on the area of interest when uploaded in Dynamic map focus #23

IndigoWizard commented 1 year ago

@PavlosDem99 I released the 1.0.0 in messy circumstances... but anyway, I also did my best to bring live a new testing branch for the current issues #22 #23 so you can now test them here: https://ndvi-viewer-1-0-1.streamlit.app/

My PC is down so I can't say when I'll work on making the app recognise different file structures, it can be a while and I'm using GitHub on mobile now, so if the app crashes I may not be able to reboot it.

If the feedback is positive on the test, I'll try to make a PR from another machine directly on GitHub and merge the branches toward a new version.