天道酬勤,学无止境

area

calculate overlapping areas

I am following the example here and successfully created convex hulls. But I have a question on how to calculate the shared areas between each convex hull in the following figure: Thanks!

2021-09-24 07:56:12    分类:问答    area   geopandas   convex-hull

使用 opencv 计算由 matplotlib 创建的轮廓的轮廓面积(Calculate contour area with opencv for contours created by matplotlib)

问题 我需要计算由等高线限制的区域。 我使用 matplotlib 来获取等高线的顶点,但我无法将它们转换为 openCV 中的 contourArea 方法的有效输入: Z = z_func(X, Y, Ql, k[i,j], B) cs = plt.contour(X, Y, Z,[IncT]) v = cs.collections[0].get_paths()[0].vertices xy = [] for vv in v: xy.append(vv[0]) cnt = np.array(xy) area = cv2.contourArea(cnt) 我收到这个错误:......\opencv-2.4.9.1\modules\imgproc\src\contours.cpp:1904: error: (-215) contour.checkVector(2) >= 0 && (contour.depth () == CV_32F || contour.depth() == CV_32S) 在函数 cv::contourArea 中 : 读取一行时的EOF 有人可以帮助我吗? 提前致谢!!! 回答1 最后,我没有使用 cv2.contourArea 方法。 只获取顶点的 Y 分量,将它们的绝对值相加并乘以网格大小: x = arange(-1.0,10.0,0.05) y =

2021-09-14 07:50:08    分类:技术分享    python   opencv   matplotlib   contour   area

在另一个国家内绘制许多国家(Plot many countries inside another)

问题 我想展示巴西亚马逊森林有多大,在里面绘制不同的国家。 就像这张图片: 为了实现这一点,我加载了一些 shapefile 并将它们的投影更改为可以保持面积成比例的投影,例如圆柱等面积: library(rgdal) countries <- readOGR("shp","TM_WORLD_BORDERS-0.3") countries <- spTransform(countries,CRS("+proj=cea")) amzLegal <- readOGR("shp","amazlegal") amzLegal@proj4string <- CRS("+proj=longlat") amzLegal <- spTransform(amzLegal,CRS("+proj=cea")) plot(amzLegal) FR <- countries[which(countries$NAME == "France"),] for (i in 1:length(FR@polygons[[1]]@Polygons)) { FR@polygons[[1]]@Polygons[[i]]@coords[,1] = FR@polygons[[1]]@Polygons[[i]]@coords[,1]-7180000 FR@polygons[[1]]@Polygons[[i]]@coords[,2]

2021-09-13 18:11:39    分类:技术分享    r   map   projection   area

检查选定区域中的坐标(Check if coordinate in selected area)

问题 我有 4 个区域坐标: x1,y1 ... 等等。还有一个位置x0,y0 。 如何检查我的坐标是否在选定区域? 回答1 我将向您解释如何检查 (x0,y0) 是否位于通过 (x1,y1) 和 (x2,y2) 的线“下方”。 本质上,您希望向量 (x0-x1,y0-y1) 指向 (x2-x1, y2-y1) 的“右侧”。 这相当于说矩阵 x0-x1 y0-y1 x2-x1 y2-y1 有一个负决定因素。 所以你的条件变成 (x0-x1)(y2-y1) < (y0-y1)(x2-x1). 对于包围该区域的任何线,您都会得到这样的条件。 回答2 让 A = {x1, y1} B = {x2, y2} C = {x3, x3} D = {x4, x4} 首先,确保点形成多项式并且不在直线上。 这可以通过比较direction(AB) != direction(AC) != direction(AD) ,其中 AB、AC、AD 是方向向量。 为了确保某个点P = {x0, y0}位于多边形ABCD ,只需检查sign(AC X AP) == sign(CD X CP) == sign(DB X DP) == sign(BA X BP) 。 AC: Directional vector A -> C AP: Directional vector A -> P . . so on! . X

2021-09-11 19:31:04    分类:技术分享    geometry   coordinates   area

单击此图像的地图区域时获取 img 标签 ID(Get img tag id when click on map area of this image)

问题 我有一些像这样带有地图区域的图像数字 我需要在区域区域内单击时获取图像 ID 我可以在没有自定义区域功能实现的情况下使用 js 实现吗? UPD沙箱 UPD2发现第二个问题,其他问题。 第一个区域(红色),它被第二个图像覆盖,不能点击,区域的 z-index 不起作用。 最终更新我写了一些小的自定义函数来映射一些对象。 也许它会帮助某人: js小提琴 回答1 我希望这就是你要找的 JS小提琴示例:http://jsfiddle.net/g5Dy3/44/ HTML <img id="dotted" src="image1.jpg" usemap="#ballmap" alt="sample" /> <img id="solid" src="image2" usemap="#ballmap2" alt="sample" /> <map name="ballmap"> <area shape="circle" coords="210,120,90" href="#" alt="dotted ball" title="dotted ball" onclick="clickedMe(this);"> </map> <map name="ballmap2"> <area shape="circle" coords="126,90,70" href="#" alt="solid ball

2021-09-11 15:54:00    分类:技术分享    javascript   html   image   shape   area

如何为两条曲线下方的区域着色?(How do i color the Area below the two curves?)

问题 我有以下图形组合: import pylab as pl import numpy as np def gauss2d(x,sigma): return (1/np.sqrt(2*np.pi*sigma ))*np.exp(-1/2*(x/sigma)**2 ) def markParameters(m,s,textsigma, textmean): p1=gauss2d(s,s) p2=gauss2d(0,s) pl.annotate("", xy=(m-s, p1), xycoords='data', xytext=(m+s, p1), textcoords='data', arrowprops=dict(arrowstyle="<->", connectionstyle="arc3"),) pl.text(m,p1,textsigma,horizontalalignment='center',verticalalignment='top') pl.annotate("", xy=(m, p2*1.1), xycoords='data', xytext=(m, p2*1.1), textcoords='data', arrowprops=dict(arrowstyle="->", connectionstyle="arc3"),) pl.text(m,p2*1.1

2021-09-11 07:47:04    分类:技术分享    matplotlib   area   curve

如何为两条曲线下方的区域着色?(How do i color the Area below the two curves?)

问题 我有以下图形组合: import pylab as pl import numpy as np def gauss2d(x,sigma): return (1/np.sqrt(2*np.pi*sigma ))*np.exp(-1/2*(x/sigma)**2 ) def markParameters(m,s,textsigma, textmean): p1=gauss2d(s,s) p2=gauss2d(0,s) pl.annotate("", xy=(m-s, p1), xycoords='data', xytext=(m+s, p1), textcoords='data', arrowprops=dict(arrowstyle="<->", connectionstyle="arc3"),) pl.text(m,p1,textsigma,horizontalalignment='center',verticalalignment='top') pl.annotate("", xy=(m, p2*1.1), xycoords='data', xytext=(m, p2*1.1), textcoords='data', arrowprops=dict(arrowstyle="->", connectionstyle="arc3"),) pl.text(m,p2*1.1

2021-09-11 07:45:10    分类:技术分享    matplotlib   area   curve

Plot many countries inside another

I want to show how big Brazilian Amazon Forest is, plotting different countries inside it. Like in this image: To accomplish that, I loaded some shapefiles and changed their projection to one that would keep the areas proportional, like Cylindrical Equal Area: library(rgdal) countries <- readOGR("shp","TM_WORLD_BORDERS-0.3") countries <- spTransform(countries,CRS("+proj=cea")) amzLegal <- readOGR("shp","amazlegal") amzLegal@proj4string <- CRS("+proj=longlat") amzLegal <- spTransform(amzLegal,CRS("+proj=cea")) plot(amzLegal) FR <- countries[which(countries$NAME == "France"),] for (i in 1:length

2021-09-09 04:29:12    分类:问答    r   map   projection   area

Get img tag id when click on map area of this image

I have some images-figures with map-area like this and i need get image id when click inside area zone can i made it without custom area functional realisation with js? UPD sandbox UPD2 found second, other problem. first area zone (red), which covered by second image not clickable and z-index for area not working. FINAL UPD I wrote small custom function for mapping some objects. Maybe it will help someone: jsFiddle

2021-09-07 15:25:04    分类:问答    javascript   html   image   shape   area

Can I have an onclick event on a imagemap area element?

I would like to put an onclick event on an area element. Here is my setup: <img id="image" src="wheel.png" width="2795" height="2795" usemap="#Map" > <map name="Map"> <area class="blue" onclick="myFunction()" shape="poly" coords="2318,480,1510,1284" href="#"> </map> I have tried 2 different ways to have an onclick event. Firstly i tried this: $(".blue").click( function(event){ alert('test'); }); I have also tried this: function myFunction() { alert('test'); } Neither of the above work. Do area elements support the above, or do they only support having a href?

2021-09-06 11:36:46    分类:问答    javascript   jquery   onclick   area   imagemap