PostGIS:Search Geometric Position - postgis

I'm working on a system that stores latitude/longitude information of addresses in a PostGIS table. To store Lat/Long in geometry data type I'm using ST_GeometryFromText function.
For example the following function call gets the geometric value against the specified Lat/Long position:
myPointGeo = ST_GeometryFromText('POINT(40.758871 -73.985114));
Similarly, I convert a Polygon into geometric representation as follows:
myPolygonGeo = ST_GeometryFromText('POLYGON ((40.7566484549725 -73.9878561496734, 40.7556894646734 -73.9853026866913, 40.7545841705587 -73.9860537052154, 40.7548036054111 -73.9881458282471, 40.7559820394514 -73.9887895584106, 40.7566484549725 -73.9878561496734 ))')
I want to find out whether the above lat/long position resides within this Polygon or not. For this I'm using ST_Within function. But though 'myPointGeo' actually resides within the Polygon, ST_Within is returning false. I'm using ST_Within this way:
St_Within(myPointGeo,myPolygonGeo)
What am I doing wrong here? Should I use some other function for this purpose?

The query looks correct. It returns false since the point is not in the polygon. The two geometries are disjoint.

Related

Need to create a return type function in Processing that returns whether one position will overlap with another

Good evening, I have been having some trouble with return type functions in Processing and I was wondering if someone could explain for example this one to me:
I have an array arrType[3], each index randomly stores an arc shape. I am supposed to draw these in random arrPosX and arrPosY, both of 50 positions/indexes. The assignment asks me to make a return type function to check if the shape overlaps with another, but I'm having a hard time with this as a return type only returns 1 value, or at least I think so? So how can I check both X and Y?
Use a function called intersects for this.
 The function gets the random x and y position,
 and returns whether this will overlap with any of the other shapes already in the array.
 You can assume that they are all circles for this, and check if they are too close based on the size
 Take the stroke of 3 into account to do the overlap check
Thank you in advance!

How to mark some grid points on netcdf map?

I can make 2D dimensional netcdf maps of some quantity. I open it in panoply and there is color map of that quantity. But I cannot visualize some boolean value.
Can I somehow mark particular grid points with some symbol on the map (it can be diamond, square, triangle... whatever), is there a way how to do it in Fortran90? I accept also python related help.
Again: I mean there would be color map (from real values) (which I can do) and at the same time some values will have e. g. triangle on it.
If I understand the question correctly, then you can easily do that with Python and using some plotting library (e.g Matplotlib). With Fortran it is extremely tricky as it does not natively support plotting in my mind.
Basically with Python you just have to :
read the wanted variables (coordinates and the field itself)
make the map of the field i.e make the plot
find the locations you want to highlight and just add those locations to the plot

What's the result of point's projection method using the RGeo::Geographic.simple_mercator_factory

I have a factory RGEO_FACTORY = RGeo::Geographic.simple_mercator_factory
And I have a point(POINT (28.97566007 41.01452809)), whose srid is 3785.
Then I get a new coordinate using RGEO_FACTORY.point(lon, lat).projection. And it's POINT (3225555.7243913896 5014484.790030423)
Now, I need to use the sql to query to improve the speed. Like this:"SELECT ST_AsText(ST_Transform(lat_lon, 4326)) from points WHERE points.id = 1" . I expect to get the same result as POINT (3225555.7243913896 5014484.790030423). But I can't get it.
And I have tried other srid to transform the coordinate of the point, but in vain.
What should I do to solve this?
Thanks in advance.
When you use RGeo::Geographic.simple_mercator_factory to create points, like you do with RGEO_FACTORY.point(lon, lat), their srid is predefined by the factory, and it's not 3785, it's 4326, see the docs for yourself. And these points' projection method returns points in 3785. Learn the actual srid of your lat_lon field with ST_SRID(lat_lon), if it's a geometry type, then figure out which srid you want to covert it to.
Covered that in more details answering another similar question.

Set Parent of Map Axes in Matlab GUI

I am programming a basic GUI in MATLAB that utilizes the mapping toolbox. The GUI will display a grayscale image and then plot discrete points over the data, all of this over the necessary map projection. It is important that I plot onto map axes (those created by the axesm command) rather than the vanilla cartesian space. I have no problem doing all this from the command line, but I cannot find a way to implement a GUI version and its driving me nuts.
The problem is that I need to specify the map axes as being the child of the parent figure. The normal axes has a property that can be set, doing something like:
axesHandle = axes('Parent', parentHandle, ...);
or
set(axesHandle, 'Parent', parentHandle);
However, there is no equivalent parent property for the map axes created by the axesm function, so I have no way to manipulate the axes within the figure. How can I do this?
Update: If I create a plot within the map axes in an empty figure, get(figureHandle, 'Children') returns the handle of the axesm object (thanks #slayton!), so the map axes object must be implicitly added to the children of the figure by MATLAB.
Should I be concerned that the map axes do not refer back to the parent figure, or should I just let it be? I wonder if this is a classic case of MATLAB forcing me to not comply with the standards the manual tells me to implement.
From reading your question what I think you are trying to do is grab the handle of the axes object. This can be done as the axes is created using either axes or subplot
a = axes();
a = subplot(x,y,z);
% both return an handle to the newly created axes object
Additionally if the axes is created automagically by a function call like plot or image you can get the axes handle that too:
p = plot(1:10); %returns a handle to a line object
a = get(p,'Parent');
i = image(); %returns a handle to an image object
a = get(i, 'Parent');
Finally, neither of those two options is available you can always get the axes handle from its containing figure with:
a = get(figureHandle, 'Children');
Remember though that this will return a vector of axes handles if your figure contains more than one axes.
Finally when it comes time to draw draw your points to the axes that contains your map image you simply need to call:
line(xPoints, yPoints, 'linestyle', 'none', 'marker', '.', 'color', 'r', 'size', 15)
This will draw the vertices of the line using large red dots.
I'm not sure if this answers your question because the code you provided doesn't line up with the question you asked.
The code you provided looks like you are trying to move an axes from one figure to another. You can totally do this!
f = figure('Position', [100 100 100 100]);
a = axes('Parent', f);
pause
f2 = figure('Position', [250 100 100 100]);
set(a,'Parent', f2);
After much trial and error and reading of documentation, I have found that there is no way to explicitly specify the parent of the map axes. Instead, they are implicitly added on top of the current axes. In the instance that no axes exist in the current figure, calling axesm creates an axes object and then places the axesm object inside. When you take this route, you have to grab the axes object handle by calling gca:
mapAxesHandle = axesm(...);
axesHandle = gca(...);
This makes it frustrating to use the mapping toolbox when writing a GUI from scratch, but that's the way Mathworks makes it happen. Thanks to #slayton for useful info. I'd upvote but my reputation is <15 :(

Plotting Address on Virtual Earth

How can I plot a point of an address on a map?
I want to basically use VEMap.Find(), but simply get the coordinates of the location.
When you call Find(), pass in true for the showResults parameter. The Microsoft doc has an example of how to do this: Microsoft's VEMap.Find() documentation
If you really only want the lat/long of a result returned from VEMap.Find(), check out this blog post: Getting Coordinates from VEMap.Find(). The coordinates are accessible in the GetCoordinates function as properties of the findPlaceResults object.

Resources