0

I need to define spatial domains over various types of data collected in my field of study. Each collection is performed at a georeferenced point.

So I need to define the spatial domains through clustering. And generate a map with the domains defined in the georeferenced points. Grateful.

Good. I have jupyter notebook, pandas, scikit-learn, openpyxl installed.Image A. georeferenced points in the study area Image B. example of map generated by GS+ on NDVI data Image C. example of the data I have in excel

Edit: I added the code, which I managed to run

import pandas as pd
import numpy as np
from sklearn.decomposition import PCA
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt

data = pd.read_excel('areafoliartotal.xlsx')

display(data)

pca = PCA(n_components=2)
pca_data = pca.fit_transform(data)

kmeans = KMeans(n_clusters=3)
kmeans.fit(pca_data)

plt.scatter(pca_data[:, 0], pca_data[:, 1], c=kmeans.labels_)
plt.title('PCA with KMeans Clustering')
plt.xlabel('PC1')
plt.ylabel('PC2')
plt.show()

Result

start with the basics, but like all beginners it is difficult to understand everything. Discover this method of defining spatial domains through this article EVALUATION OF CLUSTERING TECHNIQUES FOR DEFINING STATIONARY DOMAINS SUPPORTED BY GEOSTATISTICS

Ferretto
  • 1
  • 1
  • Quite the tale. But what is your question? – Grismar Apr 12 '23 at 23:03
  • I need to define the spatial domains through clustering. And generate a map with the domains defined in the georeferenced points. Maps similar to the ones I uploaded. – Ferretto Apr 12 '23 at 23:08
  • Please provide enough code so others can better understand or reproduce the problem. – Community Apr 12 '23 at 23:55
  • It looks like your question is "can someone please write me some code?" - and that's not what StackOverflow is for. Please share what you tried, be specific about the problem you're having and ask an actual question about that. – Grismar Apr 13 '23 at 04:16
  • I agree with the other commenters: you need to edit your question to share your code and ask a more directed question. In the meantime, you have some learning to do. I recommend following a tutorial for a package like [`verde`](https://github.com/fatiando/verde), e.g. [this one](https://www.fatiando.org/tutorials/notebooks/gravity-processing.html). It will get you a very long way. – Matt Hall Apr 13 '23 at 07:53
  • I added the code, which I managed to run – Ferretto Apr 14 '23 at 14:33
  • @matt-hall the link you sent, is exactly what I need. For KMeans++ results to be distributed directly over each coordinate. I will try to do it here. Grateful. – Ferretto Apr 16 '23 at 03:41

0 Answers0