Comments (11)
Hi @juangallegozamorano !
Thanks for opening the issue!
- The grid plot extent is currently set to (-180,180) and (-90, 90). You can changed it to your CRS extent by setting
plot_xlims
andplot_ylims
params during model class initiation. For exampleplot_xlims=(-64000, 64000)
. I will add an auto-estimator in the next PR. - The girds are generated based on your input data. So it makes less sense to project the grids to another CRS, and imaginably they will be twisted if you do that.
- You can still access the grids by calling
model.ensemble_df
.
from stemflow.
@juangallegozamorano There is not function implemented for this in stemflow. But you can do:
from stemflow.utils.jitterrotation.jitterrotator import JitterRotator
from shapely.geometry import Polygon
import geopandas as gpd
# define a function
def geo_grid_geometry(line):
old_x, old_y = JitterRotator.inverse_jitter_rotate(
[line['stixel_calibration_point_transformed_left_bound'], line['stixel_calibration_point_transformed_left_bound'], line['stixel_calibration_point_transformed_right_bound'], line['stixel_calibration_point_transformed_right_bound']],
[line['stixel_calibration_point_transformed_lower_bound'], line['stixel_calibration_point_transformed_upper_bound'], line['stixel_calibration_point_transformed_upper_bound'], line['stixel_calibration_point_transformed_lower_bound']],
line['rotation'],
line['calibration_point_x_jitter'],
line['calibration_point_y_jitter'],
)
polygon = Polygon(list(zip(old_x, old_y)))
return polygon
# Make a geometry attribute for each stixel
model.ensemble_df['geometry'] = model.ensemble_df.apply(geo_grid_geometry, axis=1)
model.ensemble_df = gpd.GeoDataFrame(model.ensemble_df, geometry='geometry')
Which creates a spatial object for each stixel.
Then:
model.ensemble_df.plot(alpha=0.2)
The stixel will stack on the temporal dimension. You may want to pick only one time range (since the spatial splitting pattern will be the same for all temporal windows in one ensemble).
model.ensemble_df[
(model.ensemble_df['DOY_start']>=90) & (model.ensemble_df['DOY_start']<120)
].plot(alpha=0.2)
Which will look less messy.
You may also want to add scatter points on top of this:
fig,ax = plt.subplots()
model.ensemble_df[
(model.ensemble_df['DOY_start']>=90) & ((model.ensemble_df['DOY_start']<120))
].plot(alpha=0.2,ax=ax)
ax.scatter(
X_train['longitude'],
X_train['latitude'],
c='tab:orange',s=0.2,alpha=0.7
)
plt.show()
Cheers!
from stemflow.
I just tried again and now I can see the stixels...I cannot explain why there were empty geometries before, thanks a lot and sorry for the hassle!
from stemflow.
Hi @chenyangkang, I accessed the ensemble_df
but unfortunately I'm not able to plot the stixels. Can you tell me how to do it? Thanks!
from stemflow.
Thanks a lot!! This is really helpful!
from stemflow.
Hi @chenyangkang, for some reason the geometries are all empty in my case...
from stemflow.
@juangallegozamorano You could provide details e.g. the model.ensemble_df original data frame for debugging purpose.
from stemflow.
Here are two examples of ensemble_df that I would like to represent in a figure
53970_larcan_ensemble_grid.csv
Common_Gull_ensemble_df.csv
from stemflow.
@juangallegozamorano I cannot reproduce the bug. This is what I got for 53970_larcan_ensemble_grid.csv
:
data = pd.read_csv('53970_larcan_ensemble_grid.csv', index_col=0)
from stemflow.utils.jitterrotation.jitterrotator import JitterRotator
from shapely.geometry import Polygon
import geopandas as gpd
# define a function
def geo_grid_geometry(line):
old_x, old_y = JitterRotator.inverse_jitter_rotate(
[line['stixel_calibration_point_transformed_left_bound'], line['stixel_calibration_point_transformed_left_bound'], line['stixel_calibration_point_transformed_right_bound'], line['stixel_calibration_point_transformed_right_bound']],
[line['stixel_calibration_point_transformed_lower_bound'], line['stixel_calibration_point_transformed_upper_bound'], line['stixel_calibration_point_transformed_upper_bound'], line['stixel_calibration_point_transformed_lower_bound']],
line['rotation'],
line['calibration_point_x_jitter'],
line['calibration_point_y_jitter'],
)
polygon = Polygon(list(zip(old_x, old_y)))
return polygon
# Make a geometry attribute for each stixel
data['geometry'] = data.apply(geo_grid_geometry, axis=1)
data = gpd.GeoDataFrame(data, geometry='geometry')
![image](https://private-user-images.githubusercontent.com/59206195/344734560-13cca5b5-9d31-409d-b63d-ed300576c907.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE0MjI5MzcsIm5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TcxN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFhMDg4YzYxM2M2YTJkYWI0MGI4ZTFhZDkyZmE2ZmI3MTFhOTdiMTI0M2QzNDg0MDQ2YTQzZDExNjUxM2Q5NDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TaNqAxIWFsfuR5OakxcYJE92ZzFVWqU1S4GrVYym9W4)
from stemflow.
I also successfully plotted the Common_Gull_ensemble_df.csv
. Maybe you could provide more information? For example:
add a "print" line in the function:
def geo_grid_geometry(line):
old_x, old_y = JitterRotator.inverse_jitter_rotate(
[line['stixel_calibration_point_transformed_left_bound'], line['stixel_calibration_point_transformed_left_bound'], line['stixel_calibration_point_transformed_right_bound'], line['stixel_calibration_point_transformed_right_bound']],
[line['stixel_calibration_point_transformed_lower_bound'], line['stixel_calibration_point_transformed_upper_bound'], line['stixel_calibration_point_transformed_upper_bound'], line['stixel_calibration_point_transformed_lower_bound']],
line['rotation'],
line['calibration_point_x_jitter'],
line['calibration_point_y_jitter'],
)
polygon = Polygon(list(zip(old_x, old_y)))
print(polygon) # this line should print out the polygon string.
return polygon
from stemflow.
No worries! Good to hear you solved it!
from stemflow.
Related Issues (19)
- [REVIEW] JOSS feedback HOT 6
- [REVIEW] consider adding automated testing HOT 2
- [REVIEW] consider updating contributor guidelines HOT 2
- [JOSS review] paper revision
- [JOSS review] Improve cartesian indexing system HOT 2
- [JOSS review] Add spherical indexing system HOT 1
- [JOSS review] Documentation revision HOT 1
- [Feature] STEM module HOT 1
- [Feature] Speed boost? Using Geo indexing dependency HOT 2
- Revise the documentation for sphere indexing and mini_test
- [Feature] Make parallel computing available HOT 1
- Add Numba for numpy operation optimization HOT 1
- [BUG] unique_stixel_id HOT 3
- Add Spatial and Temporal Scale Warnings
- NAs detection
- Check random state for all function
- Gridding params grid search
- [BUG]plot_gif only work for global and WGS84 currently HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stemflow.