Recently when I tried to create a Polygon instance in Django (version 3.1) I got this error:
GEOSException at /
Error encountered checking Geometry returned from GEOS C function "GEOSGeom_createLinearRing_r".
Here's my coordinates that I'm using:
Polygon((51.558994, -0.16349), (51.552505, -0.121468), (51.527564, -0.179695), (51.527564, -0.179695))
These coordinates are just a sample.
I'm using Polygon coordinates from the leaflet, but when I try to create django.contrib.gis.geos.polygon.Polygon Instance, I get that error.
Do have any idea or approach to store received coordinate from leaflet to polygon in Django?
Polygon first and last coordinate should be identical ( linear ring )
Related
I have an unstructured grid vtk file that contains three different types of cells (Tetrahedral, Wedge and Hexahedral). This file contains multiple Scalars (8 attributes such as Pressure, Temperature e.t.c.) and a Single Vector (U,V,W) and I am trying to create a surface plot from this file for a Scalar or Vector at a time using the Vedo python wrapper for vtk. The vtk file contains a scalar or vector value for each cell, including the point coordinates.
I have read the documentation over and over, with examples here https://vtkplotter.embl.es/content/vtkplotter/index.html. These are the things that I have tried with the challenge that I am having with each method:
Method 1: Loading the file as a TetMesh
vp = Plotter()
test = load('Case_60.vtk')
vp.show(test)
This method doesn't plot Scalar Values and only shows points. No Solid Surface. Tried using a cuttertool() with it , it throws an error saying non-Tetrahedral Cell Encountered.
Method 2: Using the UGrid
ug = UGrid('Case_60.vtk')
show(ug)
This method plots as surface with a solid color. Does not seem to be picking the Scalars.
What is the proper way for me to display surface plot and display the scalar value for each cell? Is Vedo able to do what I'm trying to do?
You might need to specify which array is to be used for coloring, e.g.:
from vedo import *
ug = UGrid(datadir+'limb_ugrid.vtk')
print(ug.getArrayNames())
ug.selectCellArray('chem_0')
show(ug, axes=True)
if this doesn't work for your mesh please submit an issue here.
I am trying to create a simple robot simulator with 3D + 2D(bird-eye view mini-map) like the below image.
My map file is just a list of vertices for polygon and center/radius for circles (all objects are heights of 1 where z = 0).
I found that python VTK plotter makes it really easy to visualize simple object but there is a lack of documentation for the multi-view windows. I also tried open-cv but it creates a 2D image in a separate window.
What would be the easiest way to achieve a simulator like below? There would be very few objects on the map so efficiency is not my concern.
My strategy for making a 2D mini-map overlay like this is to use glWindowPos2d and glDrawPixels, and I have found it to be very successful. You'll want to turn off common OpenGL features like texturing, lighting, and the depth test. In the following example, minimap_x and minimap_y are the window coordinates of the upper-left corner of the minimap.
For example:
glDisable(GL_TEXTURE_2D)
glDisable(GL_LIGHTING)
glDisable(GL_DEPTH_TEST)
glWindowPos2d(minimap_x, window_height - (minimap_y + minimap_height))
glDrawPixels(minimap_width, minimap_height, GL_RGBA, GL_UNSIGNED_BYTE, minimap_image)
glEnable(GL_TEXTURE_2D)
glEnable(GL_LIGHTING)
glEnable(GL_DEPTH_TEST)
You'll need to provide the minimap_image data.
In my applications, I'm typically using PyGame, and so the minimap is on a PyGame Surface. Converting the Surface to raw image data usable by glDrawPixels looks like this:
minimap_image = pygame.image.tostring(minimap_surface, "RGBA", True)
I am using the latest networkx on Python3 with Linux Mint 17. I am using the pcalg method (https://github.com/keiichishima/pcalg) to build directed acyclic graphs from data. I checked to be sure that the graph has edges using the number_of_edges() function.
My code looks like this:
skel_1, sep_1 = alg.estimate_skeleton(ci.ci_test_dis, Mat_1, 0.1)
dag_1 = alg.estimate_cpdag(skel_1, sep_1)
num_edge1 = dag_1.number_of_edges()
print(num_edge1)
nx.draw_networkx(dag_1, arrows=True, edge_color='b')
plt.savefig("Target1.png")
plt.close()
When I execute this code, the nodes show up, but not the edges. Is this because I did not include the pos parameter?
so i got an image with a curve, and i got a function that looks for 1 pixel and then connect the adjacent pixels (like forming a path), but somehow when it is going south-west or west it does not find any pixels even if there is one.
the function goes like:
pixels=img.getpixels()
window=((1,0),(0,-1),(-1,0),(0,1),(1,1),(1,-1),(-1,-1),(-1,1))
objs=[]
obj=[pixels.pop(),]
while pixels:
p=obj[-1]
neighbours=tuple((x+p[0],y+p[1]) for x,y in window)
for n in neighbours:
if n in pixels:
obj.append(n)
pixels.remove(n)
break
if p==obj[-1]:
objs.append(obj)
obj=[pixels.pop(),]
and an example of the failure:
the original image
the objects image
each different color represents a different "object"
should it not be showing just one object?
i appreciate any thoughts on this, tyvm :D
Ok, I am trying to upload a .csv file, get it into a spatial points data frame and set the projection system to WGS 84. I then want to determine the distance between each point This is what I have come up with but I
cluster<-read.csv(file = "cluster.csv", stringsAsFactors=FALSE)
coordinates(cluster)<- ~Latitude+Longitude
cluster<-CRS("+proj=longlat +datum=WGS84")
d<-dist2Line(cluster)
This returns an error that says
Error in .pointsToMatrix(p) :
points should be vectors of length 2, matrices with 2 columns, or inheriting from a SpatialPoints* object
But this isn't working and I will be honest that I don't fully comprehend importing and manipulating spatial data in R. Any help would be great. Thanks
I was able to determine the issue I was running into. With WGS 84, the longitude comes before the latitude. This is just backwards from how all the GPS data I download is formatted (e.g. lat-long). Hope this helps anyone else who runs into this issue!
thus the code should have been
cluster<-read.csv(file = "cluster.csv", stringsAsFactors=FALSE)
coordinates(cluster)<- ~Longitude+Latitude
cluster<-CRS("+proj=longlat +datum=WGS84")