Index: /issm/trunk-jpl/src/m/coordsystems/flaglatlongradiuselements.m
===================================================================
--- /issm/trunk-jpl/src/m/coordsystems/flaglatlongradiuselements.m	(revision 24887)
+++ /issm/trunk-jpl/src/m/coordsystems/flaglatlongradiuselements.m	(revision 24887)
@@ -0,0 +1,24 @@
+function outelements=flaglatlongradiuselements(elements,lat,long,lat0,long0,radius)
+%FLAGLATLONGRADIUSELEMENTS - given a vector of lat,long, and a circle of radius degrees around lat0,long0, 
+%                    return the indices into lat,long that are within this circle. 
+%                    lat and long should be between -90 and 90, and -180 and +180 respectively. 
+
+	distance=sqrt( (lat-lat0).^2+ (long-long0).^2);
+	
+	%three cases, depending on whether our circle goes past the -180 +180 longitude line: 
+	if (long0-radius)<=-180,
+		pos=find(long>0); long(pos)=long(pos)-360;
+	elseif (long0+radius)>=180,
+		pos=find(long<0); long(pos)=360+long(pos);
+	else
+	end
+	distance=sqrt( (lat-lat0).^2+ (long-long0).^2);
+	indices=find(distance<=radius);
+
+	%now that we know the indices, determine elements which own these indices: 
+	outelements=zeros(length(elements),1);
+	for i=1:length(indices),
+		[pos,dummy]=find(elements==indices(i));
+		outelements(pos)=1;
+	end
+	outelements=find(outelements);
Index: /issm/trunk-jpl/src/m/coordsystems/flagradiuselements.m
===================================================================
--- /issm/trunk-jpl/src/m/coordsystems/flagradiuselements.m	(revision 24887)
+++ /issm/trunk-jpl/src/m/coordsystems/flagradiuselements.m	(revision 24887)
@@ -0,0 +1,20 @@
+function outelements=flagradiuselements(elements,x,y,z,lat0,long0,radius)
+
+	%get x0,y0,z0: 
+	R=planetradius('earth');
+	x0 = R .* cosd(lat0) .* cosd(long0);
+	y0 = R .* cosd(lat0) .* sind(long0);
+	z0 = R .* sind(lat0);
+
+
+	distance=sqrt( (x-x0).^2+ (y-y0).^2 + (z-z0).^2);
+	
+	indices=find(distance<=radius*1000);
+
+	%now that we know the indices, determine elements which own these indices: 
+	outelements=zeros(length(elements),1);
+	for i=1:length(indices),
+		[pos,dummy]=find(elements==indices(i));
+		outelements(pos)=1;
+	end
+	outelements=find(outelements);
