-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First stab at intersections
extension module
#15
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…t shapely linestring as global variable
tlestang
force-pushed
the
linestring_from_python
branch
2 times, most recently
from
July 16, 2021 17:13
69787b3
to
577a764
Compare
tlestang
force-pushed
the
linestring_from_python
branch
from
July 16, 2021 17:17
577a764
to
9447ebd
Compare
tlestang
force-pushed
the
linestring_from_python
branch
from
July 16, 2021 17:29
c158070
to
ecf8c73
Compare
tlestang
force-pushed
the
linestring_from_python
branch
from
July 16, 2021 17:42
076ad08
to
cf506b4
Compare
tomalrussell
approved these changes
Jul 26, 2021
…ataset and returns geodf
…ad of temporary file.
This adresses a FutureWarning raised by numpy: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result. expected_raster_values = np.tile(raster_data[data_array_indices], 2)
Restructure python side of intersection code
Raster to vector attribution
Add a command line interface to intersections kernel
Build intersections extension
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This wraps the
findIntersectionsLinestring
function into a C++ function that takes a ShapelyLineString
and raster metadata and compute splits according to grid intersections. The function returns a list of Shapely linestrings.Its prototype is
The input Shapely object is explicitly converted to a C++ vector of points, i.e.
std::vector<Vec2>
The split calculation remains unchanged, based on the
findIntersectionsLineString
function. Finally the vector of split is converted back to a vector of Shapely linestrings:In the above,
SHPLY_LINESTR
is the ShapelyLineString
, imported in C++ via pybind11:The C++ function is based on explicit conversion between Python and C++ types (see snail#14). I don't think this is the most efficient nor elegant approach, but this takes us a step further nonetheless. My may concern is performance: looping over a large geodataframe and converting each geometry might be slow. We could measure the time required to convert back and forth and compare it to the type needed to cmpute the splits.
Building and Using the module
The module can be built with
cmake -Bbuild . cmake --build build/ --target intersections
For now, the module ends up in
build/
and therefore this module must be added tosys.path
. A next task is to update the setup script to build and install properly.The module can be used as follows:
See tests/test_intersections.cpp.