What change in the code would you make so that the polygon doesn't join like-features? What I mean is, each vector attribute is it's own feature/row of data rather than being dissolved?
Hi sir, while I try to import the gdal, ogr and osr from osgeo, one error is coming that osgeo module is not available. what should i do? thank you in advance.
Try installing Gdal. So, if you are using jupyter notebook from anaconda, try this in one of the cell: conda install -c conda-forge gdal --y. After that, run this code again "from osgeo import gdal, ogr, osr". Let me know if this solve your problem
@@mohdhassanin8292 1. Uninstalling GDAL with: pip uninstall gdal 2. Installing the GDAL wheels from www.lfd.uci.edu/~gohlke/pythonlibs/#gdal (follow the instructions on the website in your question concerning python and windows version). you can use: pip install GDAL-2.2.4-cp36-cp36m-win_amd64.whl see original post: gis.stackexchange.com/questions/259902/gdal-importerror-dll-load-failed-the-specified-module-could-not-be-found
@@mohdhassanin8292 Run an environment first "conda create -n [environment name] python=3.9" Then use "conda install -c conda-forge GDAL python=3.9" (plus any other modules you want to install). I installed Geopandas, GDAL, Fiona, Shapely and Pandas using this method after days of having import issues. Personally I didn't have much luck with wheel files.
Very useful video. I appreciate it. However, I tried to replicate it, but I encountered the following problem. TypeError Traceback (most recent call last) Cell In[21], line 3 1 proj=raster.GetProjection 2 shp_proj = osr.SpatialReference() ----> 3 shp_proj.ImportFromWkt(proj) 5 output_file = os.path.join(sub_dir, '2021CDL_Landuse.shp') 6 call_drive = ogr.GetDriverByName('ESRI Shapefile') File C:\ProgramData\Anaconda3\envs\myspatial\Lib\site-packages\osgeo\osr.py:756, in SpatialReference.ImportFromWkt(self, *args) 754 def ImportFromWkt(self, *args): 755 r"""ImportFromWkt(SpatialReference self, char ** ppszInput) -> OGRErr""" --> 756 return _osr.SpatialReference_ImportFromWkt(self, *args) TypeError: not a string Does anyone have any suggestions, including the presenter? I am grateful for your answer in advance.
Hello! raster = gdal.Open(r'MNC_verano-2023/MNC_verano-2023.tif') raster band + raster.GetRasterBand(1) band --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[37], line 1 ----> 1 band + raster.GetRasterBand(1) 2 band NameError: name 'band' is not defined What is this error?
What change in the code would you make so that the polygon doesn't join like-features? What I mean is, each vector attribute is it's own feature/row of data rather than being dissolved?
Can ı do same process with land use land cover data (netcdf format).
Yes, you can do it. You just need to read the netcdf file using Gdal.Open(). i.e. raster = gdal.Open(r'filename.nc')
Very useful! Thank you!
i run the code exactly same as you did, but my google colab always showing crashed for many times. i haven't made the effort.. what could go wrong?
Thank you for a video
My pleasure
How do I do the opposite, convert a shapefile to raster?
Hi John, I will publish that video on Friday
@@geogislabs ok, continue with the videos, they are very interesting. I will sign up!
Hi sir,
while I try to import the gdal, ogr and osr from osgeo, one error is coming that osgeo module is not available.
what should i do?
thank you in advance.
Try installing Gdal. So, if you are using jupyter notebook from anaconda, try this in one of the cell: conda install -c conda-forge gdal --y. After that, run this code again "from osgeo import gdal, ogr, osr". Let me know if this solve your problem
@@geogislabs sure sir, I will try this and I will be back soon.
Thank you
@@geogislabs this error came- DDL load failed while importing_gdal: specified module could not be found.
@@mohdhassanin8292
1. Uninstalling GDAL with:
pip uninstall gdal
2. Installing the GDAL wheels from www.lfd.uci.edu/~gohlke/pythonlibs/#gdal (follow the instructions on the website in your question concerning python and windows version). you can use:
pip install GDAL-2.2.4-cp36-cp36m-win_amd64.whl
see original post: gis.stackexchange.com/questions/259902/gdal-importerror-dll-load-failed-the-specified-module-could-not-be-found
@@mohdhassanin8292 Run an environment first "conda create -n [environment name] python=3.9"
Then use "conda install -c conda-forge GDAL python=3.9" (plus any other modules you want to install). I installed Geopandas, GDAL, Fiona, Shapely and Pandas using this method after days of having import issues.
Personally I didn't have much luck with wheel files.
Very useful video. I appreciate it. However, I tried to replicate it, but I encountered the following problem.
TypeError Traceback (most recent call last)
Cell In[21], line 3
1 proj=raster.GetProjection
2 shp_proj = osr.SpatialReference()
----> 3 shp_proj.ImportFromWkt(proj)
5 output_file = os.path.join(sub_dir, '2021CDL_Landuse.shp')
6 call_drive = ogr.GetDriverByName('ESRI Shapefile')
File C:\ProgramData\Anaconda3\envs\myspatial\Lib\site-packages\osgeo\osr.py:756, in SpatialReference.ImportFromWkt(self, *args)
754 def ImportFromWkt(self, *args):
755 r"""ImportFromWkt(SpatialReference self, char ** ppszInput) -> OGRErr"""
--> 756 return _osr.SpatialReference_ImportFromWkt(self, *args)
TypeError: not a string
Does anyone have any suggestions, including the presenter? I am grateful for your answer in advance.
You should try adding the parentheses in the GetProjection function. project = raster.GetProjection() and see if it works
Hello!
raster = gdal.Open(r'MNC_verano-2023/MNC_verano-2023.tif')
raster
band + raster.GetRasterBand(1)
band
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[37], line 1
----> 1 band + raster.GetRasterBand(1)
2 band
NameError: name 'band' is not defined
What is this error?
Hi! when i run shp_layer = create_shp.CreateLayer('Layer1', srs = shp_proj), it says the Layer already exists. How can I fix this?