├── .gitignore ├── LICENSE ├── classification.ipynb ├── data ├── LULC.tif ├── LULC_Segment.tif ├── LULC_Shapefile.cpg ├── LULC_Shapefile.dbf ├── LULC_Shapefile.prj ├── LULC_Shapefile.shp ├── LULC_Shapefile.shx ├── Sample_LC_v1.geojson └── lc.json ├── readme.md └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .venv 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2024 Ramadhan https://github.com/ramiqcom 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /data/LULC.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiqcom/lc-classification-python/a6e6cd40232e2588432d31983354e0a5a838f9dc/data/LULC.tif -------------------------------------------------------------------------------- /data/LULC_Segment.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiqcom/lc-classification-python/a6e6cd40232e2588432d31983354e0a5a838f9dc/data/LULC_Segment.tif -------------------------------------------------------------------------------- /data/LULC_Shapefile.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /data/LULC_Shapefile.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiqcom/lc-classification-python/a6e6cd40232e2588432d31983354e0a5a838f9dc/data/LULC_Shapefile.dbf -------------------------------------------------------------------------------- /data/LULC_Shapefile.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] -------------------------------------------------------------------------------- /data/LULC_Shapefile.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiqcom/lc-classification-python/a6e6cd40232e2588432d31983354e0a5a838f9dc/data/LULC_Shapefile.shp -------------------------------------------------------------------------------- /data/LULC_Shapefile.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiqcom/lc-classification-python/a6e6cd40232e2588432d31983354e0a5a838f9dc/data/LULC_Shapefile.shx -------------------------------------------------------------------------------- /data/lc.json: -------------------------------------------------------------------------------- 1 | { 2 | "palette": [ 3 | "006400", 4 | "228B22", 5 | "4B0082", 6 | "808000", 7 | "32CD32", 8 | "90EE90", 9 | "FF4500", 10 | "F08080", 11 | "D2B48C", 12 | "ADFF2F", 13 | "87CEFA", 14 | "6A5ACD", 15 | "6B8E23", 16 | "66CDAA", 17 | "FFD700", 18 | "FFA500", 19 | "008080", 20 | "E6E6FA", 21 | "B22222", 22 | "C71585", 23 | "A0522D", 24 | "7FFFD4" 25 | ], 26 | "values": [ 27 | 2001, 2002, 2004, 2005, 2006, 2007, 2010, 2012, 2014, 3000, 5001, 20041, 28 | 20051, 20071, 20091, 20092, 20093, 20094, 20121, 20122, 20141, 50011 29 | ], 30 | "label": [ 31 | "Primary dryland forest", 32 | "Secondary dryland forest", 33 | "Primary mangrove forest", 34 | "Primary swamp forest", 35 | "Plantation forest", 36 | "Dry shrub", 37 | "Estate crop", 38 | "Settlement", 39 | "Bare ground", 40 | "Savanna and grasses", 41 | "Open water", 42 | "Secondary mangrove forest", 43 | "Secondary swamp forest", 44 | "Wet shrub", 45 | "Pure dry agriculture", 46 | "Mixed dry agriculture", 47 | "Paddy field", 48 | "Fish pond/aquaculture", 49 | "Port or harbour", 50 | "Transmigration areas", 51 | "Mining", 52 | "Swamp" 53 | ] 54 | } 55 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Land Cover Classification with Python # 2 | 3 | This script purpose is to do land cover classification solely using Python 4 | 5 | I made it to challenge myself that it is possible to do the same approach as in Google Earth Engine using open source solution 6 | 7 | I used multiple library for this script such as GeoPandas and pandas to load the vector file/database and plot it, Rasterio to load and handle raster data, Scikit-learn to do machine learning, Matplotlib of course to plot, Numpy obviously for raster/array manipulation, PIL for showing raster data, Scikit-image for image segmentation, and SciPy for statistics analysis 8 | 9 | Overall, it is much harder to do than in Google Earth Engine but it is a good approach since we are using open source solution which don't need license 10 | 11 | You can use this script, modify it etc.. just don't forget to credit me 12 | 13 | Created by Ramadhan 14 | 15 | [Email](ramiqcom@gmail.com) 16 | [LinkedIn](https://linkedin.com/in/ramiqcom) 17 | [GitHub](https://github.com/ramiqcom) 18 | [Youtube](https://youtube.com/@ramiqcom) 19 | 20 | ## Instruction ## 21 | Before running the script make sure that you: 22 | 1. Have installed Python, at least version 3.9 23 | 2. Know how to code, some machine learning, and remote sensing knowledge (if don't please learn some first! it is for your own good!) 24 | 25 | If you have done 1 and 2, now you can: 26 | 1. Clone this repository 27 | 2. Create Python virtual environment 28 | 3. Install the necessary package from the the requirements.txt using ```pip``` 29 | 4. Open the ```classification.ipynb``` file 30 | 5. Run the script! 31 | 32 | This script is just one method and specific parameter, it can always be adjusted based on your need. The important thing is that you know how to code, some machine learning, and remote sensing knowledge :D. I believe you can! 33 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | affine==2.4.0 2 | anywidget==0.9.13 3 | asttokens==2.4.1 4 | attrs==24.2.0 5 | beautifulsoup4==4.12.3 6 | bqplot==0.12.43 7 | branca==0.8.0 8 | certifi==2024.8.30 9 | charset-normalizer==3.4.0 10 | click==8.1.7 11 | click-plugins==1.1.1 12 | cligj==0.7.2 13 | colorama==0.4.6 14 | colour==0.1.5 15 | comm==0.2.2 16 | contourpy==1.3.0 17 | cycler==0.12.1 18 | debugpy==1.8.7 19 | decorator==5.1.1 20 | duckdb==1.1.2 21 | exceptiongroup==1.2.2 22 | executing==2.1.0 23 | filelock==3.16.1 24 | folium==0.18.0 25 | fonttools==4.54.1 26 | gdown==5.2.0 27 | geojson==3.1.0 28 | geopandas==1.0.1 29 | idna==3.10 30 | imageio==2.36.0 31 | importlib_metadata==8.5.0 32 | importlib_resources==6.4.5 33 | ipyevents==2.0.2 34 | ipyfilechooser==0.6.0 35 | ipykernel==6.29.5 36 | ipyleaflet==0.19.2 37 | ipython==8.18.1 38 | ipytree==0.2.2 39 | ipyvue==1.11.1 40 | ipyvuetify==1.10.0 41 | ipywidgets==8.1.5 42 | jedi==0.19.1 43 | Jinja2==3.1.4 44 | joblib==1.4.2 45 | jsonschema==4.23.0 46 | jsonschema-specifications==2024.10.1 47 | jupyter-leaflet==0.19.2 48 | jupyter_client==8.6.3 49 | jupyter_core==5.7.2 50 | jupyterlab_widgets==3.0.13 51 | kiwisolver==1.4.7 52 | lazy_loader==0.4 53 | leafmap==0.38.11 54 | MarkupSafe==3.0.2 55 | matplotlib==3.9.2 56 | matplotlib-inline==0.1.7 57 | nest-asyncio==1.6.0 58 | networkx==3.2.1 59 | numpy==2.0.2 60 | packaging==24.1 61 | pandas==2.2.3 62 | parso==0.8.4 63 | pillow==11.0.0 64 | platformdirs==4.3.6 65 | plotly==5.24.1 66 | prompt_toolkit==3.0.48 67 | psutil==6.1.0 68 | psygnal==0.11.1 69 | pure_eval==0.2.3 70 | Pygments==2.18.0 71 | pyogrio==0.10.0 72 | pyparsing==3.2.0 73 | pyproj==3.6.1 74 | pyshp==2.3.1 75 | PySocks==1.7.1 76 | pystac==1.10.1 77 | pystac-client==0.8.3 78 | python-box==7.2.0 79 | python-dateutil==2.9.0.post0 80 | pytz==2024.2 81 | pywin32==308 82 | pyzmq==26.2.0 83 | rasterio==1.4.1 84 | referencing==0.35.1 85 | requests==2.32.3 86 | rpds-py==0.20.0 87 | scikit-image==0.24.0 88 | scikit-learn==1.5.2 89 | scipy==1.13.1 90 | scooby==0.10.0 91 | shapely==2.0.6 92 | six==1.16.0 93 | soupsieve==2.6 94 | stack-data==0.6.3 95 | tenacity==9.0.0 96 | threadpoolctl==3.5.0 97 | tifffile==2024.8.30 98 | tornado==6.4.1 99 | tqdm==4.66.6 100 | traitlets==5.14.3 101 | traittypes==0.2.1 102 | typing_extensions==4.12.2 103 | tzdata==2024.2 104 | urllib3==2.2.3 105 | wcwidth==0.2.13 106 | whitebox==2.3.5 107 | whiteboxgui==2.3.0 108 | widgetsnbextension==4.0.13 109 | xyzservices==2024.9.0 110 | zipp==3.20.2 111 | --------------------------------------------------------------------------------